/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../mixins/input.less';
@import '../mixins/common.less';
@import '../custom.less';
@import './vars.less';
@import '../transition/icon.less';

@input-prefix-cls: ~'@{css-prefix}input';
@input-group-prefix-cls: ~'@{css-prefix}input-group';

.@{input-prefix-cls} {
  .component-css-vars-input();

  position: relative;
  font-size: var(--ti-input-font-size);
  display: inline-table;
  width: 100%;

  &::-webkit-scrollbar {
    z-index: 11;
    width: 6px;

    &:horizontal {
      height: 6px;
    }
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 5px;
    width: 6px;
    background: #b4bccc;
  }

  &::-webkit-scrollbar-corner {
    background: #fff;
  }

  &::-webkit-scrollbar-track {
    background: #fff;
  }

  &::-webkit-scrollbar-track-piece {
    background: #fff;
    width: 6px;
  }

  &.is-exceed &__suffix &__count {
    color: var(--ti-input-exceed-text-color);
    &-text-length {
      color: var(--ti-input-exceed-text-color);
    }
  }

  &.is-disabled &__inner {
    cursor: not-allowed;
    border: 1px solid var(--ti-input-disabled-border-color);
    color: var(--ti-input-disabled-text-color);
    background: var(--ti-input-disabled-bg-color);
    .placeholder(@color: var(--ti-input-placeholder-color));
  }

  &.is-disabled &__icon {
    cursor: not-allowed;

    &.@{css-prefix}svg {
      &,
      &:hover {
        fill: var(--ti-input-disabled-text-color);
      }
    }
  }

  &.is-disabled &__prefix,
  &.is-disabled &__suffix {
    .@{css-prefix}svg {
      &,
      &:hover {
        fill: var(--ti-input-disabled-text-color);
      }
    }
  }

  &.is-exceed &__inner {
    border-color: var(--ti-input-exceed-text-color);
  }

  & &__clear {
    font-size: var(--ti-input-icon-font-size);
    cursor: pointer;
    transition: color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);

    &,
    &:hover {
      fill: var(--ti-input-icon-close-text-color);
    }
  }

  & &__count {
    height: 100%;
    position: absolute;
    right: -1px;
    display: inline-flex;
    align-items: center;
    color: var(--ti-input-count-color);
    font-size: var(--ti-input-count-font-size);

    .@{input-prefix-cls}__count-inner {
      background: var(--ti-input-bg-color);
      line-height: initial;
      display: inline-block;
    }
    &-text-length {
      color: var(--ti-input-count-textlength-color);
    }
  }

  &__inner {
    width: 100%;
    border: 1px solid var(--ti-input-border-color);
    border-radius: var(--ti-input-border-radius);
    color: var(--ti-input-text-color);
    background: var(--ti-input-bg-color);
    font-size: var(--ti-input-font-size);
    height: var(--ti-input-height);
    line-height: var(--ti-input-height);
    padding: var(--ti-input-padding-vertical) var(--ti-input-padding-horizontal);
    outline: 0;
    display: inline-block;
    box-sizing: border-box;
    appearance: none;
    transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    .placeholder(@color: var(--ti-input-placeholder-text-color));

    &:hover,
    &:focus,
    &:active {
      outline: 0;
      border-color: var(--ti-input-hover-border-color);
    }

    &:focus ~ .@{input-prefix-cls}__suffix svg {
      fill: var(--ti-input-focus-icon-color);
    }

    &::-ms-clear {
      display: none;
      width: 0;
      height: 0;
    }
  }

  &__prefix,
  &__suffix {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.3s;
    text-align: center;
    color: var(--ti-input-border-color);
    display: flex;
    align-items: center;
    svg {
      fill: var(--ti-input-suffix-icon-color);
    }
  }

  &.is-active &__inner,
  &__inner:focus {
    border-color: var(--ti-input-active-border-color);
    outline: 0;
  }

  &__suffix {
    right: var(--ti-input-suffix-right);
    transition: all 0.3s;
    pointer-events: none;
    &:hover {
      cursor: pointer;
    }
  }

  &__suffix-inner {
    pointer-events: all;
    font-size: var(--ti-common-font-size-1);
    display: flex;
    justify-content: flex-start;
    align-items: center;

    &:hover svg {
      fill: var(--ti-input-focus-icon-color);
    }
  }

  &__prefix {
    left: 8px;
    transition: all 0.3s;
    font-size: var(--ti-input-icon-font-size);
    & > div {
      display: flex;
    }
  }

  &__icon {
    height: 100%;
    line-height: var(--ti-input-height);
    text-align: center;
    transition: all 0.3s;
    font-size: var(--ti-input-icon-font-size);
    fill: var(--ti-input-icon-color);
    width: var(--ti-input-suffix-icon-width);
    height: var(--ti-input-suffix-icon-height);

    &:hover {
      fill: var(--ti-input-icon-active-border-color);
    }

    &:after {
      content: '';
      height: 100%;
      width: 0;
      display: inline-block;
      vertical-align: middle;
    }

    .svg-operationfaild {
      &,
      &:hover {
        fill: var(--ti-input-icon-close-text-color);
      }
    }
  }

  &__validateIcon {
    pointer-events: none;
  }

  &-suffix &__inner {
    padding-right: var(--ti-input-suffix-padding-right);
    padding-left: var(--ti-input-suffix-padding-left);
  }

  &-prefix &__inner {
    padding-left: var(--ti-input-prefix-padding-left);
    padding-right: var(--ti-input-prefix-padding-right);
  }

  &-medium {
    .input-size(var(--ti-input-medium-height));
  }

  &-small {
    .input-size(var(--ti-input-small-height));
  }

  &-mini {
    .input-size(var(--ti-input-mini-height));
  }

  &.is-display-only {
    .@{input-prefix-cls}-display-only {
      position: relative;

      .@{input-prefix-cls}__inner {
        visibility: hidden;
        height: auto;
        line-height: inherit;
        border: 0;
      }

      &__content {
        position: absolute;
        top: 50%;
        left: 0;
        transform: translateY(-50%);
        max-width: 100%;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
    }
  }
}

.@{input-group-prefix-cls} {
  .component-css-vars-input();

  line-height: normal;
  display: inline-table;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;

  > .@{input-prefix-cls}__inner {
    vertical-align: middle;
    display: table-cell;
  }

  &__append,
  &__prepend {
    background-color: var(--ti-input-disabled-bg-color);
    color: var(--ti-input-placeholder-text-color);
    border: 1px solid var(--ti-input-border-color);
    border-radius: var(--ti-input-border-radius);
    padding: 0 20px;
    width: 1px;
    vertical-align: middle;
    display: table-cell;
    position: relative;
    white-space: nowrap;

    &:focus {
      outline: 0;
    }

    .@{css-prefix}button,
    .@{css-prefix}select {
      display: inline-block;
      margin: -10px -20px;
    }

    .@{css-prefix}button,
    .@{css-prefix}input {
      font-size: inherit;
    }

    button.@{css-prefix}button,
    div.@{css-prefix}select .@{input-prefix-cls}__inner,
    div.@{css-prefix}select:hover .@{input-prefix-cls}__inner {
      border-color: transparent;
      background-color: transparent;
      color: inherit;
      border-top: 0;
      border-bottom: 0;
    }

    .@{css-prefix}select .@{css-prefix}input.is-focus .@{input-prefix-cls}__inner {
      border-color: transparent;
    }
  }

  &-prepend .@{input-prefix-cls}__inner,
  &__append {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  &-append > div:has(>.@{input-prefix-cls}__suffix) {
    display: inline-block;
    position: relative;
    .@{input-prefix-cls}__suffix {
      top: calc(50% - 4px);
    }
  }

  &-append .@{input-prefix-cls}__inner,
  &__prepend {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }

  &__prepend {
    border-right: 0;
  }

  &__append {
    border-left: 0;
  }
}

.@{css-prefix-iconfont}-loading {
  font-size: var(--ti-common-font-size-1);
  line-height: 1;
  vertical-align: text-top;
  animation: rotating 2s linear infinite;
}

@keyframes rotating {
  0% {
    transform: rotateZ(0deg);
  }

  100% {
    transform: rotateZ(360deg);
  }
}
